package com.formulas.certification.domain.oauth.model;

import com.formulas.certification.domain.oauth.gateway.OauthClientDetailsGateway;
import com.formulas.component.domain.Entity;
import com.formulas.component.extension.BizScenario;
import jakarta.annotation.Resource;
import lombok.Data;

/**
 * 授权认证客户端实体
 * @author yiwannuofulasi
 * @date 2023/6/13 11:53
 */
@Entity
@Data
public class OauthClientDetailsEntity {

    private String clientId;

    private String resourceIds;

    private String clientSecret;

    private String webServerRedirectUri;

    private String authorities;

    private Integer accessTokenValidity;

    private Integer refreshTokenValidity;

    private String additionalInformation;

    private String autoapprove;

    private String clientName;

    private String scope;

    private String authorizedGrantTypes;

    private BizScenario bizScenario;

    @Resource
    private OauthClientDetailsGateway oauthClientDetailsGateway;

    public void updateOauthClientDetails() {
        // trip1: 执行行为之前可以进行规则校验（业务扩展）

        // trip2: 调用领域网关执行DB操作
        oauthClientDetailsGateway.updateOauthClientDetails(this);
    }

    public void insertOauthClientDetails(){
        // trip1: 执行行为之前可以进行规则校验（业务扩展）

        // trip2: 调用领域网关执行DB操作
        oauthClientDetailsGateway.insertOauthClientDetails(this);
    }

    public void deleteOauthClientDetails() {
        oauthClientDetailsGateway.deleteOauthClientDetails(this);
    }
}
